package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.pojo.User;
import com.itheima.dubbo.interfaces.UserAPI;
import com.itheima.dubbo.mysql.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.Wrapper;
//import com.itheima.dubbo.mysql.mapper.UserMapper;


/**
 * @项目名称: tanhua-53
 * @包名: com.itheima.dubbo.mysql.impl
 * @作者: 李云飞
 * @日期: 2021-12-03
 */

@Service
public class UserAPIImpl implements UserAPI {
@Autowired
    private UserMapper userMapper;
//查看数据库中的这个用户
    @Override
    public User findUserByPhoneNum(String phone) {
        User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
                .eq(User::getMobile, phone)
        );
//返回这个手机号的用户
        System.out.println("用户信息为"+user);
        return user;
    }

//添加新用户
    @Override
    public User insertNewUser(User user) {
        userMapper.insert(user);
        return user;
    }
}
